#define GLFW_INCLUDE_VULKAN
#include <GLFW/glfw3.h>
#include "toy2d.hpp"

int main() {
    glfwInit();

    glfwWindowHint(GLFW_CLIENT_API, GLFW_NO_API);
    GLFWwindow* window = glfwCreateWindow(1920, 1080, "Vulkan window", nullptr, nullptr);

    unsigned int count;
    const char** extensions;
    extensions = glfwGetRequiredInstanceExtensions(&count);

    for (unsigned int i = 0; i < count; i++) {
        std::cout << extensions[i] << std::endl;
    }

    toy2d::Init(extensions, [&](vk::Instance instance) {
        VkSurfaceKHR surface;
        VkInstance rawInstance = instance;
        std::cout << instance << std::endl;
        if (!glfwCreateWindowSurface(rawInstance, window, NULL, &surface)) {
            throw std::runtime_error("can not create surface!");
        }
        std::cout << surface << std::endl;
        return surface;
        }, 1920, 1080);

    while (!glfwWindowShouldClose(window)) {
        glfwPollEvents();
    }

    toy2d::Quit();

    glfwDestroyWindow(window);

    glfwTerminate();

    return 0;
}